//01部门商品，UPC前三位为021或前5位为00400,如果查询不到成对Item信息，
//则错误提示：01部门散装商品不存在链交叉商品
var result_52 = JSON.parse('{"CODE":0, "ACTION":"","LEVEL":"", "MSG":"","DATA":"","RULE":"result_52"}');
var BULK_LIST = !isNull(JSON_BULK_LIST) ? JSON.parse(JSON_BULK_LIST) : [];
var CROSS_REF = !isNull(JSON_CROSS_REF) ? JSON.parse(JSON_CROSS_REF) : [];
var item021;
var item004;
var flag = 0;

function checkBulkList(BULK_LIST, CROSS_REF) {
  for (var j = 0; j < BULK_LIST.length; j++) {
    if (BULK_LIST[j].UPC_NBR.toString().substr(0, 2) == '21') {
      item021 = BULK_LIST[j].ITEM_NBR;
    }
    if (BULK_LIST[j].UPC_NBR.toString().substr(0, 3) == '400') {
      item004 = BULK_LIST[j].ITEM_NBR;
    }
    continue;
  }
  if (BULK_LIST.length <= 1 && (isNull(item021) || isNull(item004))) {
    for (var j = 0; j < CROSS_REF.length; j++) {
      if (CROSS_REF[j].UPC_NBR.toString().substr(0, 2) == '21' && isNull(item021)) {
        item021 = CROSS_REF[j].ITEM_NBR;
      }
      if (CROSS_REF[j].UPC_NBR.toString().substr(0, 3) == '400' && isNull(item004)) {
        item004 = CROSS_REF[j].ITEM_NBR;
      }
      continue;
    }
  }
}

checkBulkList(BULK_LIST, CROSS_REF);
if (DEPT_NBR == 1
  && parseInt(FINELINE / 100) == 2
  && (UPC_NBR.toString().substr(0, 2) == '21' || UPC_NBR.toString().substr(0, 3) == '400')
  && (isNull(item021) || isNull(item004))) {
  result_52.CODE = 2;
  result_52.ACTION = "CHECKING_REPORT";
  result_52.MSG = "01部门散装商品不存在链交叉商品";

}
JSON.stringify(result_52);
